<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script type="text/javascript" src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
</head>
<script>
    $(function () {
        $('#pagination').twbsPagination({
            totalPages:${result.pages},
            startPage:${result.pageNum},
            visiblePages:${result.pageSize},
            first: "首页",
            prev: "上一页",
            next: "下一页",
            last: "莫邪",

            onPageClick: function (event, page) {
                $('#currentPage').val(page);
                $("#searchForm").submit();
            }
        });

        $(".transMeBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#customertId").val(data.id)
            $("#customerName").val(data.name)
            $("#oldSellerId").val(data.sellerId)
            $("#oldSellerName").val(data.sellerName)
            $("#newSellerId").val(<@shiro.principal property="id"/>)
            $("#newSellerId").prop("disabled",true)
            $("#myModal").modal('show')
        })

        $(".transBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#customertId").val(data.id)
            $("#customerName").val(data.name)
            $("#oldSellerId").val(data.sellerId)
            $("#oldSellerName").val(data.sellerName)
            $("#newSellerId").val(<@shiro.principal property="id"/>)
            $("#newSellerId").prop("disabled",false)
            $("#myModal").modal('show')
        })

        $(".saveBtn").click(function () {
            $("#newSellerId").prop("disabled",false)
            $("#editForm").ajaxSubmit(function (data) {
                showMessager(data);
            })
        })
    })


</script>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">潜在客户管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/customerPool/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入姓名/电话">
                </div>

                <button id="btn_query" class="btn btn-default">查询</button>
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>电话</th>
                    <th>qq</th>
                    <th>职业</th>
                    <th>来源</th>
                    <th>营销人员</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${(entity.name)!}</td>
                    <td>${(entity.age)!}</td>
                    <td>${((entity.gender)==1)?string("男","女")}</td>
                    <td>${(entity.tel)!}</td>
                    <td>${(entity.qq)!}</td>
                    <td>${(entity.job.title)!}</td>
                    <td>${(entity.source.title)!}</td>
                    <td>${(entity.seller.name)!}</td>

                    <td><#if (entity.status)! == 2>
                        客户池资源
                    </#if></td>
                    <td>
                        <a class="btn btn-info btn-xs transMeBtn " data-jsonstr='${(entity.jsonString)!}'>
                            <span class="glyphicon glyphicon-pencil "></span>移交给我
                        </a>
                        <@shiro.hasAnyRoles name="admin,marker_manager">
                            <a class="btn btn-info btn-xs transBtn " data-jsonstr='${(entity.jsonString)!}'>
                                <span class="glyphicon glyphicon-pencil "></span>移交
                            </a>
                        </@shiro.hasAnyRoles>
                    </td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<div class="modal fade " tabindex="-1" id="myModal" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">移交管理</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTransfer/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" id="statusId" name="status" value="${qo.status}">
                    <div class="form-group">
                        <label for="customertId" class="col-sm-3 control-label">客户名称：</label>
                        <div class="col-sm-6">
                            <input type="hidden" class="form-control" id="customertId" name="customer.id"  >
                            <input type="text" class="form-control" id="customerName" name="customer.name" readonly >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="oldSellerId" class="col-sm-3 control-label">旧营销人员：</label>
                        <div class="col-sm-6">
                            <input type="hidden" class="form-control" id="oldSellerId" name="oldSeller.id"  >
                            <input type="text" class="form-control" id="oldSellerName" name="oldSeller.name" readonly >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="newSellerId" class="col-sm-3 control-label">新营销人员：</label>
                        <div class="col-sm-6">
                            <select name="newSeller.id" class="form-control" id="newSellerId">
                            <#list (sellers)! as s>
                                <option class="form-control" value="${s.id}">${s.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="reason" class="col-sm-3 control-label">移交原因：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="reason" name="reason"
                                   placeholder="请输入移交原因">
                        </div>
                    </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary saveBtn">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->



</body>
</html>